﻿@{
    ViewBag.Title = "Common Command";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
       
<ol class="breadcrumb">
    <li><a href="/Home/Home">Home</a></li>
    <li><a href="/Common/CommonIntoduction"> Sanelib Common</a></li>
    <li class="active">Service-Crypto Grapher</li>
</ol>

<div id="introduction">
    <h1 class="text-left">CryptoGrapher</h1>
    <p><strong>ICryptoGrapher Interface</strong><br/>In ICryptographer Interface that defines three methods First CreateSalt type Method which have return string.second ComputeHash type Method has one parameter type of string which have return string.third type Method GetPasswordHash have two parameter Password and salt type of string which have return string type .
    <pre><code>public interface ICryptographer<br/>{<br/>string CreateSalt();<br/>string ComputeHash(string valueToHash);<br/>string GetPasswordHash(string password, string salt);<br/>}</code></pre>
    Here,this Cryptographer is extend by ICryptographer from<strong>Common ClassLibrary </strong> in <strong>Service Project </strong> Show in Below. 
    <pre><code>public class Cryptographer : ICryptographer<br/>{<br/>public string CreateSalt()<br/>{<br/>const int size = 64;<br/>var rng = new RNGCryptoServiceProvider();<br />var buff = new byte[size];<br/>rng.GetBytes(buff);<br/>return Convert.ToBase64String(buff);<br/>}<br/>}<br/></code></pre>
    In,CreateSalt() method Create salt for encrypting user passwords.That Generate a cryptographic random number and Return a Base64 string representation of the random number in PasswordRsetHandler and ChangePasswordProcessor.
    <br/>In Cryptographer hase contains ComputeHash Method show in Below.
    <pre><code>public string ComputeHash(string valueToHash)<br/>{<br/>HashAlgorithm algorithm = SHA512.Create();<br/>byte[] hash = algorithm.ComputeHash(Encoding.UTF8.GetBytes(valueToHash));<br/>return Convert.ToBase64String(hash);<br/>}<br/></code></pre>
    <p>Here,this Method Create a password hash based on a password and salt and return Return  a  Base64 string representation in ChangePasswordProcessor ,PasswordRecoveredHandler ,PasswordResetHandler and AccountRecoveryController .</p>
    In Cryptographer has also contains GetPasswordHash show in Below.
    <pre><code>public string GetPasswordHash(string password, string salt)<br/>{<br />return ComputeHash(password + salt);<br/>}<br/></code></pre>
    <p>this method make Password Combination with password and salt and return to AuthenticationService.</p>
</div>

      